/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.utp.proyectobd;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author JOSE
 */
public class Inicio extends javax.swing.JFrame {

    /**
     * Creates new form Inicio
     */
    public Inicio() {
        initComponents();
        
        pregistra.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        bregistraor = new javax.swing.JButton();
        bregact = new javax.swing.JToggleButton();
        bestadoprod = new javax.swing.JToggleButton();
        bveract = new javax.swing.JToggleButton();
        pregistra = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        bregorq = new javax.swing.JButton();
        tfecha = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        rbes = new javax.swing.JRadioButton();
        rbotra = new javax.swing.JRadioButton();
        bentprod = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Orquideas");

        jLabel1.setText("Sistema de Orquideas");

        bregistraor.setText("Registrar Orquidea");
        bregistraor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bregistraorActionPerformed(evt);
            }
        });

        bregact.setText("Registrar Actividad");
        bregact.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bregactActionPerformed(evt);
            }
        });

        bestadoprod.setText("Estado producto");
        bestadoprod.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bestadoprodActionPerformed(evt);
            }
        });

        bveract.setText("Actividades");
        bveract.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bveractActionPerformed(evt);
            }
        });

        jLabel2.setText("Fecha de siembra:");

        bregorq.setText("Registrar");
        bregorq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bregorqActionPerformed(evt);
            }
        });

        tfecha.setText("23-5-2013");

        jLabel3.setText("Tipo: ");

        rbes.setText("Espiritu Santo");

        rbotra.setText("Phalaenopsis ");

        javax.swing.GroupLayout pregistraLayout = new javax.swing.GroupLayout(pregistra);
        pregistra.setLayout(pregistraLayout);
        pregistraLayout.setHorizontalGroup(
            pregistraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pregistraLayout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addGroup(pregistraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pregistraLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(tfecha, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pregistraLayout.createSequentialGroup()
                        .addGroup(pregistraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(bregorq)
                            .addGroup(pregistraLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(rbes)))
                        .addGap(18, 18, 18)
                        .addComponent(rbotra)))
                .addContainerGap(90, Short.MAX_VALUE))
        );
        pregistraLayout.setVerticalGroup(
            pregistraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pregistraLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(pregistraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tfecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pregistraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(rbes)
                    .addComponent(rbotra))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                .addComponent(bregorq)
                .addGap(60, 60, 60))
        );

        bentprod.setText("Entrada Producto");
        bentprod.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bentprodActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(114, 114, 114)
                        .addComponent(pregistra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(256, 256, 256)
                                .addComponent(jLabel1))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(bregistraor)
                                .addGap(18, 18, 18)
                                .addComponent(bregact)
                                .addGap(18, 18, 18)
                                .addComponent(bveract)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bentprod)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bestadoprod)))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel1)
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bregistraor)
                    .addComponent(bregact)
                    .addComponent(bveract)
                    .addComponent(bentprod)
                    .addComponent(bestadoprod))
                .addGap(28, 28, 28)
                .addComponent(pregistra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bregistraorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bregistraorActionPerformed

        
        pregistra.setVisible(true);
        
        
    }//GEN-LAST:event_bregistraorActionPerformed

    private void bregactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bregactActionPerformed
       RegAct regacti = new RegAct();
       
       regacti.setVisible(true);
        
        
        
    }//GEN-LAST:event_bregactActionPerformed

    private void bregorqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bregorqActionPerformed

        //registra las plantas en la bd
        
        ClaseRegPlanta reg = new ClaseRegPlanta();
        String  fecha = null;
        int tipo = 0;
        int ultimo = 0;
        boolean registro = false;
      
        fecha = tfecha.getText();
        
        if(rbes.isSelected()){
           
        tipo = 1;
        }
        if(rbotra.isSelected()){
        
        tipo = 2;
        
        }
        
        reg.setFecha(fecha);
        reg.setTipo(tipo);
        try {
            registro =  reg.RegistroPlanta();
            ultimo = reg.UltimoRegistro();
           
           
           if(registro = true){
           JOptionPane.showMessageDialog(null, "Orquidea registrada correctamente "
                   + "\n El id de la planta registrada es: " +ultimo);
           
           }
           else{
           JOptionPane.showMessageDialog(null, "ERROR AL REGISTRAR ORQUIDEA");
           }
           
        } catch (SQLException ex) {
            Logger.getLogger(Inicio.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        
    }//GEN-LAST:event_bregorqActionPerformed

    private void bestadoprodActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bestadoprodActionPerformed

        
        EstadoProd regprod = new EstadoProd();
        regprod.setVisible(true);
        
    }//GEN-LAST:event_bestadoprodActionPerformed

    private void bentprodActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bentprodActionPerformed
        
        EntProd entp = new EntProd();
        entp.setVisible(true);
        
        
    }//GEN-LAST:event_bentprodActionPerformed

    private void bveractActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bveractActionPerformed

        Actividades act = new Actividades();
        act.setVisible(true);
        
        // TODO add your handling code here:
    }//GEN-LAST:event_bveractActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Inicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Inicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Inicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Inicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Inicio().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bentprod;
    private javax.swing.JToggleButton bestadoprod;
    private javax.swing.JToggleButton bregact;
    private javax.swing.JButton bregistraor;
    private javax.swing.JButton bregorq;
    private javax.swing.JToggleButton bveract;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel pregistra;
    private javax.swing.JRadioButton rbes;
    private javax.swing.JRadioButton rbotra;
    private javax.swing.JTextField tfecha;
    // End of variables declaration//GEN-END:variables
}
